package designpattern.strategy.order;

import designpattern.strategy.order.domain.Coupon;
import designpattern.strategy.order.domain.DiscountScheme;
import designpattern.strategy.order.domain.Member;

import java.math.BigDecimal;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 刘牌
 * @Date: 2021/12/21/16:41
 * @Description:
 */
public class Client {
    public static void main(String[] args) {
        Member member = new Member("123456", "steak", new Date(), new BigDecimal("0.7"));
        IOrderDiscountStrategy<Member> birthdayStrategy = new BirthdayDiscountStrategy();
        OrderDiscountContext<Member> orderDiscountContext = new OrderDiscountContext<>(birthdayStrategy);
        BigDecimal birthday = orderDiscountContext.discount(member, new BigDecimal(584));
        System.out.println("birthday  "+birthday);

        Coupon coupon = new Coupon("88888", new BigDecimal("121.5"), "开业优惠券");
        IOrderDiscountStrategy<Coupon> couponDiscountStrategy = new CouponDiscountStrategy();
        OrderDiscountContext<Coupon> couponOrderDiscountContext = new OrderDiscountContext<>(couponDiscountStrategy);
        BigDecimal couponDiscount = couponOrderDiscountContext.discount(coupon, new BigDecimal(584));
        System.out.println("coupon  "+couponDiscount);

        DiscountScheme discountScheme = new DiscountScheme("23423423", new BigDecimal("0.7"), "七夕");
        IOrderDiscountStrategy<DiscountScheme> discountSchemeIOrderDiscountStrategy = new DiscountSchemeStrategy();
        OrderDiscountContext<DiscountScheme> discountSchemeOrderDiscountContext = new OrderDiscountContext<>(discountSchemeIOrderDiscountStrategy);
        BigDecimal discount = discountSchemeOrderDiscountContext.discount(discountScheme, new BigDecimal(1259));
        System.out.println("discountScheme   "+discount);
    }
}
